#!/bin/sh
if test $TERM = mgr
then
	echo -n "49F"
	echo -n "80,24w"
	eval `set_termcap`
fi
for i in 1 2 3 4 5 6 7 8 9 l
do
	if test -f $MANPATH/cat$i/$1.$i
	then
		if test $MANPATH/man$i/$1.$i -nt $MANPATH/cat$i/$1.$i
		then
			echo source never... reformatting $1 ...
			rm -f $MANPATH/cat$i/$1.i
			groff -v -man -Tascii $MANPATH/man$i/$1.$i > /tmp/grofftmp
			compress -f < /tmp/grofftmp > $MANPATH/cat$i/$1.$i'z'
			rm -f /tmp/grofftmp
			zcat < $MANPATH/cat$i/$1.$i'z' | less
			exit 0
		fi
		less $MANPATH/cat$i/$1.$i
		exit 0
	else if test -f $MANPATH/cat$i/$1.$i'z'
	then
		if test $MANPATH/man$i/$1.$i -nt $MANPATH/cat$i/$1.$i'z'
		then
			echo source never... reformatting $1 ...
			rm -f $MANPATH/cat$i/$1.i'z'
			groff -v -man -Tascii $MANPATH/man$i/$1.$i > /tmp/grofftmp
			compress -f < /tmp/grofftmp > $MANPATH/cat$i/$1.$i'z'
			rm -f /tmp/grofftmp
		fi
		zcat < $MANPATH/cat$i/$1.$i'z' | less
		exit 0
	else if test -f $MANPATH/man$i/$1.$i
		then echo formatting $1 ...
		groff -v -man -Tascii $MANPATH/man$i/$1.$i > /tmp/grofftmp
		compress -f < /tmp/grofftmp > $MANPATH/cat$i/$1.$i'z'
		rm -f /tmp/grofftmp
		zcat < $MANPATH/cat$i/$1.$i'z' | less
		exit 0
	fi ; fi; fi; 
done
echo No manualpage for $1
exit 1
